#include "RocksStoreDB.h"

int RocksStoreDB::open()
{
	options.IncreaseParallelism();
	options.OptimizeLevelStyleCompaction();
	options.create_if_missing = true;
	Status s = DB::Open(options, db_path, &db);
	if (s.ok())
		return 0;
	else
		return -1;
}

int RocksStoreDB::close()
{
	return 0;
}
  
int RocksStoreDB::set(string &key, string *value)
{
	Status s = db->Put(WriteOptions(), key, *value); //TODO type change
	if (s.ok())
		return 0;
	else
		return -1;
}

int RocksStoreDB::get(string &key, string *value)
{
	Status s = db->Get(ReadOptions(), key, value);
	if (s.ok()) {
		return 0;
	} else if (s.IsNotFound()) {
		return 1;
	} else {
		return -1;
	}
}

int RocksStoreDB::remove(string &key)
{
	Status s = db->Delete(WriteOptions(), key);
	if (s.ok())
		return 0;
	else
		return -1;	
}

